home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power Programmierung
/
Power-Programmierung (Tewi)(1994).iso
/
magazine
/
pctchnqs
/
1991
/
number1
/
test.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1989-12-14
|
1KB
|
46 lines
program Test;
{ A simple program to illustrate the usage of the stack objects }
uses BaseObj,Stacks;
type TestObjPtr = ^TestObj;
TestObj = object(Base) { Just a simple object }
Contents: string;
constructor Init(S: string);
procedure Display;
end;
constructor TestObj.Init(S: string);
{ Create a new test object }
begin
Contents := S
end;
procedure TestObj.Display;
{ Display the contents of a test object }
begin
writeln(Contents);
end;
var Ch: char;
TestStack: Stack; { This is the error!!! }
TempTestObj: TestObjPtr;
begin
TestStack.Init; { Create the stack object }
for Ch := 'A' to 'E' do { Put some objects on stack }
begin
new(TempTestObj,Init(Ch)); { Create a new TestObj }
TestStack.Push(TempTestObj^); { Push it on stack }
dispose(TempTestObj,Done) { Destroy the TestObj again }
end;
while not TestStack.Empty do { Show what's on the stack }
begin
TempTestObj := TestObjPtr(TestStack.Pop);
TempTestObj^.Display
end
end.